home *** CD-ROM | disk | FTP | other *** search
- /*
- patterned curve.c
-
- This file contains the calls to create a "thick" curve and fill it will a "star" as the pattern.
-
- NOTES:
- • This file requires the new "GX"-ified interface files and libraries. With the interface files, all types and function
- names are proceeded by a "gx" for types or "GX" for function names.
-
- • This file requires the following files to run correctly:
- "graphics shell.c", "ColorLibrary.c", "GraphicsDebugLibrary.c", "ShapeLibrary.c", "TransformLibrary.c".
-
- • This file prints the "best" in landscape mode.
-
- Change History:
-
- 4/96 bob Updated #includes to support changed GX Library names.
- Updated the note regarding the files needed to run.
- Updated the copyright date.
-
- ©1992 - 1996 Apple Computer, Inc.
- All rights reserved.
- */
-
- #include <events.h>
- #include <windows.h>
-
- #include "FontLibrary.h"
- #include <GXErrors.h>
- #include "GraphicsLibraries.h"
- #include <GXEnvironment.h>
- #include "graphics shell.h"
-
- //
- // Set up the title and size of the window
- //
- Str255 gWindowTitle = "\p Patterned Curve";
- Rect gWindowQDRect = {50, 20, 235, 375};
-
- //
- // gGraphicsHeapSize sets the size of the graphics heap created by calling the NewGraphicsClient routine
- // in main () within graphics shell.c. You can determine the amount of graphics heap required by using GraphicsBug.
- // With gGraphicsHeapSize set to 25k, I had 3 free blocks left in the graphics heap. Sounds good to me.
- //
- long gGraphicsHeapSize = 25;
-
- gxShape gShape;
-
- /*------ DoInitialization ---------------------------------------------------------------------------------*/
-
- void DoInitialization(gWindow)
- WindowPtr gWindow;
- {
- gxCurve curveGeometry = {ff(25), ff(125), ff(100), 0, ff(225), ff(125)};
- gxShape starShape, testRect;
- gxRectangle starShapeBounds;
- gxPatternRecord starPattern;
-
- long starGeometry[] = {1, // number of contours
- 5, // number of points
- ff(60), 0, ff(90), ff(90), ff(0), ff(30), ff(120), ff(30), ff(0), ff(90)}; // the points
-
- InitCommonColors();
-
- gShape = GXNewCurve (&curveGeometry);
-
- //
- // Create a star gxShape which will be used as the fill pattern
- //
- starShape = GXNewPolygons((gxPolygons *) starGeometry);
- GXScaleShape(starShape, fl(0.25), fl(0.25), 0, 0);
-
- //
- // Get the bounds of our star gxShape. We use the bounds to setup the u and v vectors of the pattern
- // record. We want "gShape" to be filled with the star where each star is placed at edge of the
- // previous star (i.e so the pattern's do not overlap).
- //
- GXGetShapeBounds(starShape, 0L, &starShapeBounds);
-
- starPattern.u.x = 0;
- starPattern.u.y = starShapeBounds.bottom;
- starPattern.v.x = starShapeBounds.right + fixed1;
- starPattern.v.y = 0;
-
- starPattern.attributes = gxPortAlignPattern;
- starPattern.pattern = starShape;
-
- GXSetShapePattern(gShape, &starPattern);
-
- //
- // We can dispose of our star gxShape because it is now referenced from within the
- // pattern record contained in "gShape".
- //
- GXDisposeShape (starShape);
-
- SetShapeCommonColor (gShape, blue);
- GXSetShapePen (gShape, ff(75));
- GXMoveShape (gShape, ff(50), 0);
- }
-
- /*------ DoClick ---------------------------------------------------------------------------------------*/
-
- void DoClick( orgMouseLoc, theWindow )
- gxPoint orgMouseLoc;
- WindowPtr theWindow;
- {
- }
-
-
- /*------ DoDraw ---------------------------------------------------------------------------------------*/
-
- void DoDraw(gWindow)
- WindowPtr gWindow;
- {
- GXDrawShape (gShape);
- }
-
-
- /*------ DoDispose -------------------------------------------------------------------------------------*/
-
- void DoDispose(gWindow)
- WindowPtr gWindow;
- {
- /**
- You should always dispose of your GX graphics objects before tossing your window. Why? It's generally good
- form and this approach guarantees that everything is disposed. If you had not disposed of everything, the
- call to DisposeWindow should dispose of the objects. If you are running the debugging version of the
- SecretGraphics init with notices set, you will receive a notice that you had not disposed of everything. You
- can turn notices on in this file by setting gDebugging = TRUE (above).
- **/
- GXDisposeShape(gShape);
- GXDisposeShape(gWindowBoundsShape);
- DisposeCommonColors();
- DisposeWindow(gWindow);
- }
-
-
-
- /*------ DoIdle ----------------------------------------------------------------------------------------*/
-
- void DoIdle(gWindow)
- WindowPtr gWindow;
- {
- }
-